<?php
/*
Plugin Name: Add This
Plugin URI: http://getlilina.org/
Description: Enables the sharing of items via the Add This service.
Author: Ryan McCue
Version: 1.0
Author URI: http://ryanmccue.info/
*/

/**
 * Add the link to the item actions
 *
 * @param array $actions Previous actions
 * @return array Array with Add This added.
 */
function addthis_widget($actions) {
	$actions[] = '<a href="http://www.addthis.com/bookmark.php?url=' . urlencode(get_the_link()) . '&amp;title=' . urlencode(get_the_title()) . '" id="#addthis-' . get_the_id() . '">Add This</a>
<script type="text/javascript">
addthis.button("#addthis-' . get_the_id() . '", {}, {url: "' . get_the_link() . '", title: "' . get_the_title() . '"});
</script>';
	return $actions;
}
add_filter('action_bar', 'addthis_widget');

/**
 * Javascript to open URL in new window
 */
function addthis_js() {
?>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4b53e7bc6e8cacc8"></script>
<?php
}
add_action('template_header', 'addthis_js');

?>